Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6627 reading dcm folder filtering filenames #7181

Merged
merged 5 commits into from
Nov 2, 2023

Conversation

wyli
Copy link
Contributor

@wyli wyli commented Nov 1, 2023

Fixes #6627

Description

adding a fname_regex option to the pydicom reader

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@wyli wyli marked this pull request as ready for review November 1, 2023 11:51
monai/data/image_reader.py Outdated Show resolved Hide resolved
@ericspod
Copy link
Member

ericspod commented Nov 1, 2023

Should we test specifically for passing a different pattern, or a pattern which matches nothing?

wyli added 4 commits November 2, 2023 10:21
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
@wyli wyli force-pushed the 6627-filtering-fname branch from 00e0025 to c205c5a Compare November 2, 2023 10:21
@wyli wyli requested a review from ericspod November 2, 2023 10:21
Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good here. We've encountered the issue here of exceptions being raised when trying to read a non-DICOM file such as the LICENSE file. The approach I've used in the past with pydicom is to try to read everything and skip over any file raising InvalidDicomError, this has unintented consequences of course. What we can do instead is use is_dicom from the library to check any file first if this doesn't have too much of a performance penalty.

@wyli
Copy link
Contributor Author

wyli commented Nov 2, 2023

Looks good here. We've encountered the issue here of exceptions being raised when trying to read a non-DICOM file such as the LICENSE file. The approach I've used in the past with pydicom is to try to read everything and skip over any file raising InvalidDicomError, this has unintented consequences of course. What we can do instead is use is_dicom from the library to check any file first if this doesn't have too much of a performance penalty.

thanks! I'm adding some exception handling for InvalidDicomError, and user can set fname_regex=None to use the is_dicom checker.

@wyli
Copy link
Contributor Author

wyli commented Nov 2, 2023

/build

@wyli wyli enabled auto-merge (squash) November 2, 2023 14:17
@wyli wyli merged commit d42440b into Project-MONAI:dev Nov 2, 2023
28 checks passed
@wyli wyli deleted the 6627-filtering-fname branch November 2, 2023 17:12
marksgraham pushed a commit to marksgraham/MONAI that referenced this pull request Jan 30, 2024
Fixes Project-MONAI#6627

### Description
adding a `fname_regex` option to the pydicom reader

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Mark Graham <[email protected]>
Yu0610 pushed a commit to Yu0610/MONAI that referenced this pull request Apr 11, 2024
Fixes Project-MONAI#6627

### Description
adding a `fname_regex` option to the pydicom reader

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Yu0610 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter only ".dcm" files when reading DICOM series
4 participants